package com.miyake.loveviewweb.server.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2012-07-11 14:41:09")
/** */
public final class ValueModelMeta extends org.slim3.datastore.ModelMeta<com.miyake.loveviewweb.shared.model.ValueModel> {

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel> caption = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel>(this, "caption", "caption");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel> id = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel>(this, "id", "id");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel, com.google.appengine.api.datastore.Key> pluginKey = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel, com.google.appengine.api.datastore.Key>(this, "pluginKey", "pluginKey", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel> subUnit = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel>(this, "subUnit", "subUnit");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel> unit = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel>(this, "unit", "unit");

    /** */
    public final org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel> value = new org.slim3.datastore.StringAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel>(this, "value", "value");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<com.miyake.loveviewweb.shared.model.ValueModel, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    private static final ValueModelMeta slim3_singleton = new ValueModelMeta();

    /**
     * @return the singleton
     */
    public static ValueModelMeta get() {
       return slim3_singleton;
    }

    /** */
    public ValueModelMeta() {
        super("ValueModel", com.miyake.loveviewweb.shared.model.ValueModel.class);
    }

    @Override
    public com.miyake.loveviewweb.shared.model.ValueModel entityToModel(com.google.appengine.api.datastore.Entity entity) {
        com.miyake.loveviewweb.shared.model.ValueModel model = new com.miyake.loveviewweb.shared.model.ValueModel();
        model.setCaption((java.lang.String) entity.getProperty("caption"));
        model.setId((java.lang.String) entity.getProperty("id"));
        model.setKey(entity.getKey());
        model.setPluginKey((com.google.appengine.api.datastore.Key) entity.getProperty("pluginKey"));
        model.setSubUnit((java.lang.String) entity.getProperty("subUnit"));
        model.setUnit((java.lang.String) entity.getProperty("unit"));
        model.setValue((java.lang.String) entity.getProperty("value"));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        com.miyake.loveviewweb.shared.model.ValueModel m = (com.miyake.loveviewweb.shared.model.ValueModel) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("caption", m.getCaption());
        entity.setProperty("id", m.getId());
        entity.setProperty("pluginKey", m.getPluginKey());
        entity.setProperty("subUnit", m.getSubUnit());
        entity.setProperty("unit", m.getUnit());
        entity.setProperty("value", m.getValue());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("slim3.schemaVersion", 1);
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        com.miyake.loveviewweb.shared.model.ValueModel m = (com.miyake.loveviewweb.shared.model.ValueModel) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        com.miyake.loveviewweb.shared.model.ValueModel m = (com.miyake.loveviewweb.shared.model.ValueModel) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        com.miyake.loveviewweb.shared.model.ValueModel m = (com.miyake.loveviewweb.shared.model.ValueModel) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
    }

    @Override
    protected void incrementVersion(Object model) {
        com.miyake.loveviewweb.shared.model.ValueModel m = (com.miyake.loveviewweb.shared.model.ValueModel) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    protected void postGet(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        com.miyake.loveviewweb.shared.model.ValueModel m = (com.miyake.loveviewweb.shared.model.ValueModel) model;
        writer.beginObject();
        org.slim3.datastore.json.Default encoder0 = new org.slim3.datastore.json.Default();
        if(m.getCaption() != null){
            writer.setNextPropertyName("caption");
            encoder0.encode(writer, m.getCaption());
        }
        if(m.getId() != null){
            writer.setNextPropertyName("id");
            encoder0.encode(writer, m.getId());
        }
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder0.encode(writer, m.getKey());
        }
        if(m.getPluginKey() != null){
            writer.setNextPropertyName("pluginKey");
            encoder0.encode(writer, m.getPluginKey());
        }
        if(m.getSubUnit() != null){
            writer.setNextPropertyName("subUnit");
            encoder0.encode(writer, m.getSubUnit());
        }
        if(m.getUnit() != null){
            writer.setNextPropertyName("unit");
            encoder0.encode(writer, m.getUnit());
        }
        if(m.getValue() != null){
            writer.setNextPropertyName("value");
            encoder0.encode(writer, m.getValue());
        }
        if(m.getVersion() != null){
            writer.setNextPropertyName("version");
            encoder0.encode(writer, m.getVersion());
        }
        writer.endObject();
    }

    @Override
    protected com.miyake.loveviewweb.shared.model.ValueModel jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        com.miyake.loveviewweb.shared.model.ValueModel m = new com.miyake.loveviewweb.shared.model.ValueModel();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.Default decoder0 = new org.slim3.datastore.json.Default();
        reader = rootReader.newObjectReader("caption");
        m.setCaption(decoder0.decode(reader, m.getCaption()));
        reader = rootReader.newObjectReader("id");
        m.setId(decoder0.decode(reader, m.getId()));
        reader = rootReader.newObjectReader("key");
        m.setKey(decoder0.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("pluginKey");
        m.setPluginKey(decoder0.decode(reader, m.getPluginKey()));
        reader = rootReader.newObjectReader("subUnit");
        m.setSubUnit(decoder0.decode(reader, m.getSubUnit()));
        reader = rootReader.newObjectReader("unit");
        m.setUnit(decoder0.decode(reader, m.getUnit()));
        reader = rootReader.newObjectReader("value");
        m.setValue(decoder0.decode(reader, m.getValue()));
        reader = rootReader.newObjectReader("version");
        m.setVersion(decoder0.decode(reader, m.getVersion()));
        return m;
    }
}